<template>
  <div class="diamonds_details">
    <div class="header">
      <img src="@/assets/images/ic_meau-arrow@2x.png" alt="" @click="backRouter" />
      <div class="name">Gems Detail</div>
    </div>
    <div class="ul_box_wrap" v-if="list.length > 0">
      <div class="diamonds_li_wrap">
        <div class="diamond_li" v-for="(item, index) in list" :key="index">
          <div class="diamond_li_left">
            <div class="left_top">{{ item.description }}</div>
            <div class="left_bottom">{{ item.createTime }}</div>
          </div>
          <div class="diamond_li_right">
            <img src="@/assets/images/ic_star_24@2x.png" alt="" />
            <span class="number">{{ item?.inoutType == 1 ? '+' : '-' }}{{ item.amount }}</span>
          </div>
        </div>
      </div>
      <div class="bottom_tip">
        <div class="topbottom_tip_first">~ Reached the end ~</div>
        <div class="topbottom_tip_second">Able to Show the Last 30 Days of Records</div>
      </div>
    </div>
    <div v-else>
      <van-empty description="No Data" />
    </div>
  </div>
</template>

<script setup>
import { useRouter } from "vue-router";
import { onMounted, ref } from "vue";
import api from "@/api";

const router = useRouter();

const backRouter = () => {
  router.back();
};

const list = ref([]);

// 查询积分余额
const getPointsTransactionPage = async () => {
  try {
    const res = await api.pointsTransactionPage();
    list.value = res.data;
  } catch (err) {
    console.log(err);
  }
};

onMounted(() => {
  getPointsTransactionPage();
});
</script>

<style scoped lang="less">
.diamonds_details {
  min-height: 100vh;
  box-sizing: border-box;
  padding-top: 56px;
  background: #e9edfb;

  .header {
    display: flex;
    box-sizing: border-box;
    justify-content: left;
    align-items: center;
    width: 100%;
    height: 56px;
    padding: 0 15px;
    position: fixed;
    background: #e9edfb;
    left: 0;
    top: 0;

    img {
      width: 32px;
      margin-right: 13px;
    }

    .name {
      font-size: 18px;
      color: #000000;
      font-weight: 500;
    }
  }

  .ul_box_wrap {
    width: 100%;
    height: calc(100vh - 56px);
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.75);
    border-radius: 12px 12px 0px 0px;
  }

  .diamonds_li_wrap {
    .diamond_li {
      height: 80px;
      box-sizing: border-box;
      padding: 0 24px;
      display: flex;
      justify-content: space-between;
      align-items: center;

      .diamond_li_left {
        display: flex;
        flex-direction: column;
        align-items: left;

        .left_top {
          color: #333;
          font-size: 18px;
          color: rgba(0, 0, 0, 0.95);
          font-weight: 700;
          text-align: left;
        }

        .left_bottom {
          margin-top: 4px;
          font-size: 14px;
          color: rgba(0, 0, 0, 0.45);
        }
      }

      .diamond_li_right {
        display: flex;
        justify-content: center;
        align-items: center;

        img {
          width: 24px;
          margin-right: 4px;
        }

        .number {
          font-size: 16px;
          font-weight: 700;
          color: #333;
        }
      }
    }

    .diamond_li:first-child {
      margin-top: 0;
    }
  }

  .bottom_tip {
    display: flex;
    justify-content: center;
    flex-direction: column;
    align-items: center;
    padding-top: 20px;
    padding-bottom: 72px;

    .topbottom_tip_first {
      font-weight: 400;
      font-size: 15px;
      color: rgba(0, 0, 0, 0.95);
      margin-bottom: 9px;
    }

    .topbottom_tip_second {
      font-size: 13px;
      color: rgba(0, 0, 0, 0.45);
    }
  }
}
</style>
